<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<script type="text/javascript">
    var ctx="${ctx}";
    var patientId='${clinicMaster.patientId}';
    var clinicId='${clinicMaster.id}';
    $(function () {
        var id = $("#id").val();
        if (id != null && id != "") {
            selectDoctor($("#inpDept").val(), $("#doctorInCharge").val());
        }
    })
    var my_register;
    function page(n,s){
        $("#pageNo").val(n);
        $("#pageSize").val(s);
        $("#searchForm").submit();
        return false;
    }
    function addWin(clinicId,id){
        var url=ctx+'/doctor/pregnantNatalcRecord/findById';
        var title='';
        if(id!=''&&id){
            //修改
            url+="?id="+id+"&clinicId="+clinicId;
            title='修改产后42天体检表';
        }
        else{
            url+="?clinicId="+clinicId;
            title='添加产后42天体检表';
        }
        my_register=layer.open({
            title:title,
            type: 2,
            area: ['1080px', '80%'],
            content: url,
            btn: ['确定', '取消'],
            yes:function(index,layero){
                butType(index,layero);
            }
        });
    }

    function butType(index,layero){
        //if ($('#inputForm').parsley().validate()) {
        var form = layer.getChildFrame('form', index);
        if (form.parsley().validate()) {
            $.ajax({
                type: "POST",
                data:form.serialize(),
                url: "${ctx}/doctor/pregnantNatalcRecord/save",
                dataType: "json",
                success: function (data) {
                    toastr.success(data.data);
                    layer.close(my_register);
                    loadDiv('rigthDoctorCenterDiv','${ctx}/doctor/pregnantNatalcRecord/index?clinicId='+clinicId)
                },
                error: function (data) {
                    toastr.error('网络连接错误,请检查网络');
                }
            });
        }
        return false;
    }
    function delRecord(id){
        $.ajax({
            type: "GET",
            url: "${ctx}/doctor/pregnantNatalcRecord/delete?id="+id,
            dataType: "json",
            success: function (data) {
                toastr.success(data.data);
                loadDiv('rigthDoctorCenterDiv','${ctx}/doctor/pregnantNatalcRecord/index?clinicId='+clinicId)
            },
            error: function (data) {
                toastr.error('网络连接错误,请检查网络');
            }
        });
        return false;
    }
    function confirmExtend(str, id) {
        layer.confirm(str, {
            skin: 'layui-layer-molv',
            btn: ['确定', '取消'] //按钮
        }, function (index) {
            delRecord(id);
            layer.close(index);
        }, function (index) {
            layer.close(index);
        });
    }
    /**
     *form表单提交load
     * @param divId
     * @param formId
     * @param url
     */
    function loadDivForm(divId, formId, url) {
        var title='';
        if($("#searchGestationalTitle").val()!=''&&$("#searchGestationalTitle").val())
            title=$("#searchGestationalTitle").val();
        url = url + '?' + $("#" + formId).serialize()+'clinicId='+clinicId+'&pageNo='+$("#pageNo").val()+'&pageSize='+$("#pageSize").val()+'&title='+title;
        setTimeout(loadDiv(divId, url), 300);
        return false;
    }

</script>
    <div class="content-wrap">
        <div class="wrapper" style="bottom: 50px;">
            <ul class="nav nav-tabs">
                <li>
                    <a href="#"   onclick="loadDiv('rigthDoctorCenterDiv','${ctx}/doctor/pregnantRecords/index?clinicId='+clinicId)">孕妇初诊记录</a>
                </li>
                <li>
                    <a href="#"   onclick="loadDiv('rigthDoctorCenterDiv','${ctx}/doctor/pregnantVisit/index?clinicId='+clinicId)">孕妇复诊记录</a>
                </li>
                <li>
                    <a href="#"   onclick="loadDiv('rigthDoctorCenterDiv','${ctx}/doctor/pregnantVisit/expertIndex?clinicId='+clinicId)">专家鉴定</a>
                </li>
                <li class="active">
                    <a href="#"   onclick="loadDiv('rigthDoctorCenterDiv','${ctx}/doctor/pregnantNatalcRecord/index?clinicId='+clinicId)">产后42天体检表</a>
                </li>
            </ul>
            <div class="panel-body">
                <div class="table-responsive no-border">
                    <div class="datatable-top">
                        <div class="pull-left">
                            <form:form id="searchForm" modelAttribute="pregnantNatalcRecord"  onsubmit="return loadDivForm('mainCenterDiv','searchFormDict','${ctx}/pregnantnatalcrecord/pregnantNatalcRecord/index');" method="post" class="form-inline">
                                <input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
                                <input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
                            </form:form>
                        </div>
                    </div>
                    <div class="form-group">
                        <input  class="btn btn-primary" type="button" value="新增" onclick="addWin('${clinicMaster.id}','')" id="addRecords"/>
                    </div>
                    <table id="contentTable" class="table table-bordered table-striped mg-t datatable">
                        <thead>
                            <tr>
                                <th>门诊号</th>
                                <th>检查时间</th>
                                <th>住院科室</th>
                                <th>主管医生</th>
                                <th>就诊科室</th>
                                <th>操作</th>
                            </tr>
                        </thead>
                        <tbody>
                        <c:forEach items="${page.list}" var="pregnantNatalcRecord">
                            <tr>
                                <td> ${pregnantNatalcRecord.clinicNo}</td>
                                <td> <fmt:formatDate value="${pregnantNatalcRecord.checkDatetime}" pattern="yyyy-MM-dd" /></td>
                                <td> ${pregnantNatalcRecord.inpDeptName}</td>
                                <td> ${pregnantNatalcRecord.doctorInChargeName}</td>
                                <td> ${pregnantNatalcRecord.visitDeptName}</td>
                                <td>
                                    <a href="#" onclick="addWin('${pregnantNatalcRecord.clinicId}','${pregnantNatalcRecord.id}')" class="btn btn-success btn-xs">修改</a>
                                    <a href="#"  class="applyBt btn btn-danger btn-xs" onclick="confirmExtend('是否确定删除？','${pregnantNatalcRecord.id}')">删除</a>
                                </td>
                            </tr>
                        </c:forEach>

                    </table>
                    <div class="pagination">${page}</div>
                </div>
            </div>
        </div>
    </div>